#ifndef USIMULAVR_H_INCLUDED
#define USIMULAVR_H_INCLUDED


#ifdef _BUILD_FOR_SIMULAVR

/* This port correponds to the "-W 0x20,-" command line option. */
#define special_output_port (*((volatile char *)0x20))

/* This port correponds to the "--writetoabort 0x22" command line option. */
#define special_exit_port  (*((volatile char *)0x22))

/* Bang the specified char out the debug port. */
int debug_putch(char c, FILE* f) {
    special_output_port = c;
	return (0);
}

void debug_exit() {
	//Write some dummy value to signal exit
	special_exit_port = 0x1;
}

#define SIMULAVR_INIT() fdevopen(debug_putch, NULL);
#define SIMULAVR_EXIT() debug_exit()
#else
#define SIMULAVR_INIT()
#define SIMULAVR_EXIT()
#endif
#endif // USIMULAVR_H_INCLUDED
